-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tool to auto-generate solidity documentation for project. #136
Add tool to auto-generate solidity documentation for project. #136
Conversation
aaf25ba
to
091e42d
Compare
For my state I'd not include in generated docs nothing more than public and external functions/variables (and events). |
Great point; pushed c103693. Admittedly, I'm not trying to get this perfect, but rather to provide the devs with something quick as a base to build on. I'm sure the theme can be refined further. |
Any thoughts on getting this merged? Not sure what the GH action failures are about:
|
I would consider replacing/extending this PR to use the mechanism @michalinacienciala is working on in keep-network/tbtc-v2#557. The real benefit from generating contract docs is when we can host them. Here is Michalina's work-in-progress documentation generated for tBTC v2: https://api-docs.threshold.network/ |
This is very timely re: a discussion @mhluongo and I recently had about threshold docs. Is https://api-docs.threshold.network/ a placeholder WIP (with the idea that api docs will eventually live on docs.threshold.network) or is the goal to have api docs live separately? |
I'm also interested in the thought process here. Any API docs would have to include subpages for various applications across Threshold and not just tBTC. We already have hosting via gitbook (docs.threshold.network) that can be leveraged. Depending on how the md files are produced by the various repositories, gitbook (used for docs.threshold.network) can import sub-pages from external sources - https://docs.gitbook.com/getting-started/import. Here is one such import I played around with - I imported directly from api-docs.threshold.network: Also here is an import from this PR for the page https://github.com/derekpierre/solidity-contracts/blob/automated-documentation/docs/contracts/Checkpoints.md: I don't believe importing sub-pages allows for automated updates when the files get updated. Perhaps it needs to be re-imported after external changes 🤷 . Alternatively, I think there are some special things you can do with files in gitbook (done via direct commits to gitbook and probably not via the UI), to directly link to external sources for the API docs files so that the data can possibly change eg. github repos. Maybe something like this - https://stackoverflow.com/questions/42248880/how-to-import-a-markdown-file-from-github-into-local-gitbook - I have not tried this before, but something that can be experimented with. Absolute worst case, we could link out to a docs folder in github with md files (but feels like we can have something reasonable instead of this). |
Agreed. The current state is just the first step. The goal is to have Solidity API from all repositories plus some other APIs, like the Typescript library for tBTC. The goal of the work @michalinacienciala is doing (see keep-network/tbtc-v2#553) was to generate documentation automatically as a part of the CI process and publish it on a website. Worth noting, we had to add some intermediate steps to the process (see keep-network/tbtc-v2#557) to ensure the end result is rendered nicely in all cases. If we can import the generated files into GitBook and do not have a separate bucket for API documentation, this would be ideal. The bucket upload is just a small step at the very end that can be easily replaced. I think we should aim at having it generated into a CI and happening automatically. Otherwise, the documentation will quickly get out of sync. I am looking at GitBook import and I do not see a way to automate HTML imports. One way we could try is to have a separate repository for HTML documentation and have an automated process to push to that repository after every |
If I understand correctly how GitBook works, it offers a two-way synchronization between itself and a GitHub repository (in our case https://github.com/threshold-network/threshold/docs). This means that any changes applied to
Some potential downsides of this solution:
What do you folks think about this? Could we do this the way I proposed? Any downsides I missed? Any solutions to the downsides I listed? |
@pdyraga , so what I propose above is a bit similar to what you wrote, but instead of pushing files to a separate repository, we would push directly to the GitBook's repo. And I think we should push the docs not on pushes to |
I saw similar problems before in workflows triggered by changes in the forked repos. This was usualy related to the fact that
I'm not sure if this practice is at fault this time, but I think there's a high chance the problem is related to the fact that the PR was crated from the fork. |
@michalinacienciala Correct, and that is the current setup.
Potentially not just once, if additional files get generated. One possible way around this could be to always include a
Good question. This would be a argument in favor of a CI workflow for releases and pushing to the gitbook repos, unless release practices are potentially modified. I guess I'm unfamiliar with the release process for other Keep repos. We, NuCypher, use the git flow model (https://nvie.com/posts/a-successful-git-branching-model/) where whatever is on If the decision is to push files from a separate repos to the Gitbook repos ( Copying my musing on Discord here about a potential alternative: Our singular docs GitBook space is currently backed by/synced to the threshold-network/threshold repos, and has one space "Threshold Docs" under the "Threshold" organization. AFAIK each GitBook space (https://docs.gitbook.com/getting-started/content-structure/what-is-a-space) can only be linked to one GitHub repos. In terms of keeping various docs synced based on content produced in various GitHub repos, I think one possibility is to use a different GitBook space for each external repos containing docs. I believe then each GitBook space can be configured to be synced to a different GitHub repos docs - https://docs.gitbook.com/getting-started/git-sync/enabling-github-sync. Of course the various repos would need to be set up to allow GitBook to pull the docs appropriately. That way changes to docs can continue to occur in these external GitHub repos, and then the corresponding GitBook space gets automatically updated. You could setup the sync as one-directional (disable live-edits) i.e. docs changes for those spaces must occur via the external git repos and not via GitBook to keep things simple especially for API type of docs. You can link from one GitBook space to another, so the general Threshold Docs GitBook space can link to the other GitBook spaces (API docs or otherwise). All spaces would be under the existing singular Threshold organization in GitBook. So potentially something like this in Gitbook:
The benefits are:
The drawbacks are:
Caveat: not claiming to be well-versed in Gitbook, just what I've gathered from reading Whatever method we end up deciding on, we should think about automating as much as possible and the ease of maintenance cost by the various teams. |
👍 Thanks for clarifying...this was a confusing one. |
I think both solutions require similar amount of work in case more files will be generated. You either have to modify
Oh, so it looks that Nu's process is different than Keep's. In Keep we merge the feature branches to
and
I don't think Keep plans to modify the release practices anytime soon, the current approach seems to work fine for us. But anyway, I'm not sure if that really is an argument in favor of using CI workflow and pushing to the GitBook repo. We could still use the approach you suggested (with storing the docs in the respective repos that would be synched with individual GitBook spaces). This could be done in one of the following ways: So I think, boiling down, the main decisions we need to take are:
I'm interested to hear what are your preferences. I hope what I wrote above didn't make the matters more confusing 😄 If anything is unclear or I missed some point / made some incorrect assumptions, please let me know! |
@pdyraga, @derekpierre, would love to hear your opinion on points 1 and 2. |
Apologies, this skipped my mind for the last few days. Thanks for laying out the different options. IMHO the simplest set-up is 1B and 2A, i.e.:
|
@michalinacienciala Is the work you are doing under keep-network/tbtc-v2#553 addressing |
Closing in favor of #138 |
Vict0r asked me to help him out with the documentation work.
Here is a first pass at using
solidity-docgen
from Open Zeppelin - https://github.com/OpenZeppelin/solidity-docgen.Happy to make edits for minor changes. If major changes are needed however, you can either merge and build on this change with subsequent PRs, OR feel free to cherry-pick the commit and make any necessary adjustments as needed in a separate PR.
See
docs/contracts
for the auto-generated output - https://github.com/derekpierre/solidity-contracts/tree/automated-documentation/docs/contracts